Processing event messages for user requests to execute program code

ABSTRACT

A service manages a plurality of virtual machine instances for low latency execution of user codes. The service can provide the capability to execute user code in response to events triggered on an auxillary service to provide implicit and automatic rate matching and scaling between events being triggered on the auxiliary service and the corresponding execution of user code on various virtual machine instances. An auxiliary service may be configured as an event triggering service to detect events and generate event messages for execution of the user codes. The service can request, receive, or poll for event messages directly from the auxiliary service or via an intermediary message service. Event messages can be rapidly converted to requests to execute user code on the service. The time from processing the event message to initiating a request to begin code execution is less than a predetermined duration, for example, 100 ms.

CROSS-REFERENCE TO CONCURRENTLY-FILED APPLICATIONS

The present application's Applicant concurrently filed the followingU.S. patent applications on Sep. 30, 2014:

-   -   Application No. Title    -   Ser. No. 14/502,589 MESSAGE-BASED COMPUTATION REQUEST SCHEDULING    -   Ser. No. 14/502,810 LOW LATENCY COMPUTATIONAL CAPACITY        PROVISIONING    -   Ser. No. 14/502,714 AUTOMATIC MANAGEMENT OF LOW LATENCY        COMPUTATIONAL CAPACITY    -   Ser. No. 14/502,992 THREADING AS A SERVICE PROGRAMMATIC EVENT        DETECTION AND MESSAGE    -   Ser. No. 14/502,648 GENERATION FOR REQUESTS TO EXECUTE PROGRAM        CODE    -   Ser. No. 14/502,620 DYNAMIC CODE DEPLOYMENT AND VERSIONING

The disclosures of the above-referenced applications are herebyincorporated by reference in their entireties.

BACKGROUND

Generally described, computing devices utilize a communication network,or a series of communication networks, to exchange data. Companies andorganizations operate computer networks that interconnect a number ofcomputing devices to support operations or provide services to thirdparties. The computing systems can be located in a single geographiclocation or located in multiple, distinct geographic locations (e.g.,interconnected via private or public communication networks).Specifically, data centers or data processing centers, herein generallyreferred to as a “data center,” may include a number of interconnectedcomputing systems to provide computing resources to users of the datacenter. The data centers may be private data centers operated on behalfof an organization or public data centers operated on behalf, or for thebenefit of, the general public.

To facilitate increased utilization of data center resources,virtualization technologies may allow a single physical computing deviceto host one or more instances of virtual machines that appear andoperate as independent computing devices to users of a data center. Withvirtualization, the single physical computing device can create,maintain, delete, or otherwise manage virtual machines in a dynamicmanner. In turn, users can request computer resources from a datacenter, including single computing devices or a configuration ofnetworked computing devices, and be provided with varying numbers ofvirtual machine resources.

In some scenarios, virtual machine instances may be configured accordingto a number of virtual machine instance types to provide specificfunctionality. For example, various computing devices may be associatedwith different combinations of operating systems or operating systemconfigurations, virtualized hardware resources and software applicationsto enable a computing device to provide different desiredfunctionalities, or to provide similar functionalities more efficiently.These virtual machine instance type configurations are often containedwithin a device image, which includes static data containing thesoftware (e.g., the OS and applications together with theirconfiguration and data files, etc.) that the virtual machine will runonce started. The device image is typically stored on the disk used tocreate or initialize the instance. Thus, a computing device may processthe device image in order to implement the desired softwareconfiguration.

BRIEF DESCRIPTION OF THE DRAWINGS

The foregoing aspects and many of the attendant advantages of thisdisclosure will become more readily appreciated as the same becomebetter understood by reference to the following detailed description,when taken in conjunction with the accompanying drawings, wherein:

FIG. 1 is a block diagram depicting an illustrative environment forprocessing event messages for user requests to execute program codes ina virtual compute system;

FIG. 2 depicts a general architecture of a computing device providing afrontend of a virtual compute system for processing event messages foruser requests to execute program codes;

FIG. 3 is a flow diagram illustrating an event notification and messagegeneration routine implemented by an auxiliary system in communicationwith a frontend of a virtual compute system, according to an exampleaspect;

FIG. 4 is a flow diagram illustrating an event message processingroutine implemented by a frontend of a virtual compute system, accordingto another example aspect; and

DETAILED DESCRIPTION

Companies and organizations no longer need to acquire and manage theirown data centers in order to perform computing operations (e.g., executecode, including threads, programs, software, routines, subroutines,processes, etc.). With the advent of cloud computing, storage space andcompute power traditionally provided by hardware computing devices cannow be obtained and configured in minutes over the Internet. Thus,developers can quickly purchase a desired amount of computing resourceswithout having to worry about acquiring physical machines. Suchcomputing resources are typically purchased in the form of virtualcomputing resources, or virtual machine instances. These instances ofvirtual machines, which are hosted on physical computing devices withtheir own operating systems and other software components, can beutilized in the same manner as physical computers.

However, even when virtual computing resources are purchased, developersstill have to decide how many and what type of virtual machine instancesto purchase, and how long to keep them. For example, the costs of usingthe virtual machine instances may vary depending on the type and thenumber of hours they are rented. In addition, the minimum time a virtualmachine may be rented is typically on the order of hours. Further,developers have to specify the hardware and software resources (e.g.,type of operating systems and language runtimes, etc.) to install on thevirtual machines. Other concerns that they might have includeover-utilization (e.g., acquiring too little computing resources andsuffering performance issues), under-utilization (e.g., acquiring morecomputing resources than necessary to run the codes, and thusoverpaying), prediction of change in traffic (e.g., so that they knowwhen to scale up or down), and instance and language runtime startupdelay, which can take 3-10 minutes, or longer, even though users maydesire computing capacity on the order of seconds or even milliseconds.Thus, an improved method of allowing users to take advantage of thevirtual machine instances provided by service providers is desired.

According to aspects of the present disclosure, by maintaining a pool ofpre-initialized virtual machine instances that are ready for use as soonas a user request is received, delay (sometimes referred to as latency)associated with executing the user code (e.g., instance and languageruntime startup time) can be significantly reduced.

Generally described, aspects of the present disclosure relate to themanagement of virtual machine instances and containers created therein.Specifically, systems and methods are disclosed which facilitatemanagement of virtual machine instances in a virtual compute system. Thevirtual compute system maintains a pool of virtual machine instancesthat have one or more software components (e.g., operating systems,language runtimes, libraries, etc.) loaded thereon. The virtual machineinstances in the pool can be designated to service user requests toexecute program codes. The program codes can be executed in isolatedcontainers that are created on the virtual machine instances. Since thevirtual machine instances in the pool have already been booted andloaded with particular operating systems and language runtimes by thetime the requests are received, the delay associated with findingcompute capacity that can handle the requests (e.g., by executing theuser code in one or more containers created on the virtual machineinstances) is significantly reduced.

In certain embodiments, a message queue, a message bus, or any othermessage intermediary service is provided to facilitate transportation orcommunication of event messages generated in a first programmaticenvironment (e.g., at an auxiliary service) to the programmaticenvironment provided by the virtual compute system described herein. Tofurther facilitate propagation and transportation of a triggered eventfrom the first programmatic environment to the virtual compute system,event messages may be generated to include information descriptive ofthe triggered event, a user associated with a request to execute usercode in response to the triggered event, and programmatic information toenable the virtual compute system to convert the event message into auser request for further processing by the virtual compute system. Theevent message and/or programmatic information contained therein may bestructured according to a schema, a code model, or an applicationprogramming interface (“API”) to facilitate both creation/generation ofthe event message at the auxiliary service and conversion/processing ofthe event message at the virtual compute system.

In another aspect, a virtual compute system may maintain a pool ofvirtual machine instances on one or more physical computing devices,where each virtual machine instance has one or more software componentsloaded thereon. When the virtual compute system receives a request toexecute the program code of a user, which specifies one or morecomputing constraints for executing the program code of the user, thevirtual compute system may select a virtual machine instance forexecuting the program code of the user based on the one or morecomputing constraints specified by the request and cause the programcode of the user to be executed on the selected virtual machineinstance.

One benefit provided by the systems and methods described herein is animplicit and automatic rate matching and scaling between events beingtriggered on an auxiliary service and the corresponding execution ofuser code on various virtual machine instances. Thus, the virtualcompute system is capable of responding to events on-demand, whether theevents are triggered infrequently (e.g., once per day) or on a largerscale (e.g., hundreds or thousands per second).

Specific embodiments and example applications of the present disclosurewill now be described with reference to the drawings. These embodimentsand example applications are intended to illustrate, and not limit, thepresent disclosure.

With reference to FIG. 1, a block diagram illustrating an embodiment ofa virtual environment 100 will be described. The example shown in FIG. 1includes a virtual environment 100 in which users (e.g., developers,etc.) of user computing devices 102 may run various program codes usingthe virtual computing resources provided by a virtual compute system110.

By way of illustration, various example user computing devices 102 areshown in communication with the virtual compute system 110, including adesktop computer, laptop, and a mobile phone. In general, the usercomputing devices 102 can be any computing device such as a desktop,laptop, mobile phone (or smartphone), tablet, kiosk, wireless device,and other electronic devices. In addition, the user computing devices102 may include web services running on the same or different datacenters, where, for example, different web services may programmaticallycommunicate with each other to perform one or more techniques describedherein. Further, the user computing devices 102 may include Internet ofThings (IoT) devices such as Internet appliances and connected devices.The virtual compute system 110 may provide the user computing devices102 with one or more user interfaces, command-line interfaces (CLI),application programing interfaces (API), and/or other programmaticinterfaces for generating and uploading user codes, invoking the usercodes (e.g., submitting a request to execute the user codes on thevirtual compute system 110), scheduling event-based jobs or timed jobs,tracking the user codes, and/or viewing other logging or monitoringinformation related to their requests and/or user codes. Although one ormore embodiments may be described herein as using a user interface, itshould be appreciated that such embodiments may, additionally oralternatively, use any CLIs, APIs, or other programmatic interfaces.

The user computing devices 102 access the virtual compute system 110over a network 104. The network 104 may be any wired network, wirelessnetwork, or combination thereof. In addition, the network 104 may be apersonal area network, local area network, wide area network,over-the-air broadcast network (e.g., for radio or television), cablenetwork, satellite network, cellular telephone network, or combinationthereof. For example, the network 104 may be a publicly accessiblenetwork of linked networks, possibly operated by various distinctparties, such as the Internet. In some embodiments, the network 104 maybe a private or semi-private network, such as a corporate or universityintranet. The network 104 may include one or more wireless networks,such as a Global System for Mobile Communications (GSM) network, a CodeDivision Multiple Access (CDMA) network, a Long Term Evolution (LTE)network, or any other type of wireless network. The network 104 can useprotocols and components for communicating via the Internet or any ofthe other aforementioned types of networks. For example, the protocolsused by the network 104 may include Hypertext Transfer Protocol (HTTP),HTTP Secure (HTTPS), Message Queue Telemetry Transport (MQTT),Constrained Application Protocol (CoAP), and the like. Protocols andcomponents for communicating via the Internet or any of the otheraforementioned types of communication networks are well known to thoseskilled in the art and, thus, are not described in more detail herein.

The virtual compute system 110 is depicted in FIG. 1 as operating in adistributed computing environment including several computer systemsthat are interconnected using one or more computer networks. The virtualcompute system 110 could also operate within a computing environmenthaving a fewer or greater number of devices than are illustrated inFIG. 1. Thus, the depiction of the virtual compute system 110 in FIG. 1should be taken as illustrative and not limiting to the presentdisclosure. For example, the virtual compute system 110 or variousconstituents thereof could implement various Web services components,hosted or “cloud” computing environments, and/or peer-to-peer networkconfigurations to implement at least a portion of the processesdescribed herein.

Further, the virtual compute system 110 may be implemented in hardwareand/or software and may, for instance, include one or more physical orvirtual servers implemented on physical computer hardware configured toexecute computer executable instructions for performing various featuresthat will be described herein. The one or more servers may begeographically dispersed or geographically co-located, for instance, inone or more data centers.

In the environment illustrated FIG. 1, the virtual environment 100includes a virtual compute system 110, which includes a frontend 120, awarming pool manager 130, and a worker manager 140. In the depictedexample, virtual machine instances (“instances”) 152, 154 are shown in awarming pool 130A managed by the warming pool manager 130, and instances156, 158 are shown in an active pool 140A managed by the worker manager140. The illustration of the various components within the virtualcompute system 110 is logical in nature and one or more of thecomponents can be implemented by a single computing device or multiplecomputing devices. For example, the instances 152, 154, 156, 158 can beimplemented on one or more physical computing devices in differentvarious geographic regions. Similarly, each of the frontend 120, thewarming pool manager 130, and the worker manager 140 can be implementedacross multiple physical computing devices. Alternatively, one or moreof the frontend 120, the warming pool manager 130, and the workermanager 140 can be implemented on a single physical computing device. Insome embodiments, the virtual compute system 110 may comprise multiplefrontends, multiple warming pool managers, and/or multiple workermanagers. Although four virtual machine instances are shown in theexample of FIG. 1, the embodiments described herein are not limited assuch, and one skilled in the art will appreciate that the virtualcompute system 110 may comprise any number of virtual machine instancesimplemented using any number of physical computing devices. Similarly,although a single warming pool and a single active pool are shown in theexample of FIG. 1, the embodiments described herein are not limited assuch, and one skilled in the art will appreciate that the virtualcompute system 110 may comprise any number of warming pools and activepools.

In the example of FIG. 1, the virtual compute system 110 is illustratedas being connected to the network 104. In some embodiments, any of thecomponents within the virtual compute system 110 can communicate withother components (e.g., the user computing devices 102 and auxiliaryservices 106, which may include monitoring/logging/billing services 107,a storage service 108, an instance provisioning service 109, a messagequeue service 105, and/or other services that may communicate with thevirtual compute system 110) of the virtual environment 100 via thenetwork 104. In other embodiments, not all components of the virtualcompute system 110 are capable of communicating with other components ofthe virtual environment 100. In one example, only the frontend 120 maybe connected to the network 104, and other components of the virtualcompute system 110 may communicate with other components of the virtualenvironment 100A via the frontend 120. In some embodiments, any of theauxiliary services 106 may be configured to operate as an eventtriggering service 106A in order to listen for events specified by usersof the auxiliary service and trigger generation of event messages forprocessing by the virtual compute system 110, as described in moredetail herein. Thus for example, the storage service 108 may beconfigured to operate as an event triggering service 106A in order toprovide the capability of executing user code on the virtual computesystem 110 in response to events as they occur on the storage service108.

In one embodiment, the one or more auxiliary services 106 may beregistered or configured to be polled or queried for events to triggerexecution of user codes on the virtual compute system 110. Suchregistration or configuration may be provided or enabled via the one ormore user interfaces provided to the user computing devices 102. Forexample, a user interface may provide options for the user to select orspecify an auxiliary service 106 as an event-triggering service 106A,such that events on the event-triggering service 106A may triggergeneration of event messages, or such that the event-triggering service106A may be periodically polled or queried for events such as by anintermediary polling system.

In one embodiment, the event triggering service 106A may be configuredto associate an event or event type with a particular program code to beexecuted on the virtual compute system 110 (that is, the eventtriggering service 106A may store or have access to data whichassociates the event with the particular program code). In anotherembodiment, the event triggering service 106A may not necessarilyassociate an event or event type with a particular program code to beexecuted on the virtual compute system 110, but rather the eventtriggering service 106A may generate event messages which the virtualcompute system 110 is configured to interpret as being associated withthe program code to be executed on the virtual compute system 110 (thatis, the virtual compute system 110 may store or have access to datawhich associates the event with the particular program code), In anotherembodiment, an intermediary system or service may be configured tohandle interpretation and routing of event messages to execute theprogram code, such that neither the event triggering service 106A northe virtual compute system 110 may store or have access to theevent-to-program code association data. For example, the eventtriggering service 106A may generate an event message that is agnosticto any particular program code to be executed; and the event message maybe routed to the virtual compute system 110 (or an intermediary system)which evaluates the event message and associated metadata to determinewhich program code to execute in response, and initiate a correspondingrequest to execute the program code.

As mentioned above, any of the auxiliary services 106 may be configuredto operate as an event triggering service 106A. These include but arenot limited to: remote storage systems; database systems; message queuesystems (for example, a message queue service provided by the virtualcompute system 110, a message queue system owned and/or operated by auser or client separate from the virtual compute system 110, and so on);web services; auditing services; health monitoring services (forexample, for monitoring health status of a virtual compute system);logging services; billing services; resource management systems andservices (for example, for managing lifecycles and/or ownership ofvirtual computing environments and the like); and so on.

Users may use the virtual compute system 110 to execute user codethereon. For example, a user may wish to run a piece of code inconnection with a web or mobile application that the user has developed.One way of running the code would be to acquire virtual machineinstances from service providers who provide infrastructure as aservice, configure the virtual machine instances to suit the user'sneeds, and use the configured virtual machine instances to run the code.Alternatively, the user may send a code execution request the virtualcompute system 110. The virtual compute system 110 can handle theacquisition and configuration of compute capacity (e.g., containers,instances, etc., which are described in greater detail below) based onthe code execution request, and execute the code using the computecapacity. The virtual compute system 110 may automatically scale up anddown based on the volume, thereby relieving the user from the burden ofhaving to worry about over-utilization (e.g., acquiring too littlecomputing resources and suffering performance issues) orunder-utilization (e.g., acquiring more computing resources thannecessary to run the codes, and thus overpaying).

The frontend 120 receives and processes all the requests (sometimes inthe form of event messages) to execute user code on the virtual computesystem 110. In one embodiment, the frontend 120 serves as a front doorto all the other services provided by the virtual compute system 110.The frontend 120 processes the requests and makes sure that the requestsare properly authorized. For example, the frontend 120 may determinewhether the user associated with the request is authorized to access theuser code specified in the request.

The user code as used herein may refer to any program code (e.g., aprogram, routine, subroutine, thread, etc.) written in a specificprogram language. In the present disclosure, the terms “code,” “usercode,” and “program code,” may be used interchangeably. Such user codemay be executed to achieve a specific task, for example, in connectionwith a particular web application or mobile application developed by theuser. For example, the user codes may be written in JavaScript(node.js), Java, Python, and/or Ruby. The request may include the usercode (or the location thereof) and one or more arguments to be used forexecuting the user code. For example, the user may provide the user codealong with the request to execute the user code. In another example, therequest may identify a previously uploaded program code (e.g., using theAPI for uploading the code) by its name or its unique ID. In yet anotherexample, the code may be included in the request as well as uploaded ina separate location (e.g., the storage service 108 or a storage systeminternal to the virtual compute system 110) prior to the request isreceived by the virtual compute system 110. The virtual compute system110 may vary its code execution strategy based on where the code isavailable at the time the request is processed.

The frontend 120 may receive the request to execute such user codes inresponse to Hypertext Transfer Protocol Secure (HTTPS) requests from auser. Also, any information (e.g., headers and parameters) included inthe HTTPS request may also be processed and utilized when executing theuser code. As discussed above, any other protocols, including, forexample, HTTP, MQTT, and CoAP, may be used to transfer the messagecontaining the code execution request to the frontend 120. The frontend120 may also receive the request to execute such user codes when anevent is detected, such as an event that the user has registered totrigger automatic request generation. For example, the user mayconfigured an auxiliary service 106 to operate as an event-triggeringservice 106A by registering the user code with the auxiliary service 106and specifying that whenever a particular event occurs (e.g., a new fileis uploaded), the request to execute the user code is sent to thefrontend 120. Alternatively, the user may have registered a timed job(e.g., execute the user code every 24 hours). In such an example, whenthe scheduled time arrives for the timed job, the request to execute theuser code may be sent to the frontend 120. A timed or scheduled job maybe implemented using the techniques of this disclosure to, for example,model the job as an event generated by a timer service. For example, thetimer service may generate an event message indicating that it is nowtime to run a user code, and the virtual compute system 110 mayimplement a process to run code at a certain time by utilizing the timerservice to remind the virtual compute system 110 to run the user code.In yet another example, the frontend 120 may include or have access to aqueue of incoming code execution requests, and when the user's batch jobis removed from the virtual compute system's work queue, the frontend120 may process the user request. In yet another example, the requestmay originate from another component within the virtual compute system110 or other servers or services not illustrated in FIG. 1.

In yet another example, the request may originate from another componentwithin the virtual compute system 110 or other servers or services notillustrated in FIG. 1. In some embodiments, a request toexecute/activate user codes may be generated in response to an eventassociated with the user computing device 102 or an auxiliary service106. For example, in response to an end user uploading a new image froma user computing device to an auxiliary service (such as storage service108) configured to operate as an event triggering service 106A, theevent triggering service 106A can trigger a request to execute/activatea code to generate a thumbnail of the image. The code may be hosted inthe active pool 120 or downloaded from a storage service storage service108 to the virtual compute system 110.

In any of the examples described above and throughout this disclosure,an event message representative of a request to execute the user codemay be initially received by a message queue service 105 and provided toor placed in a message queue. The message queue service 105 may beimplemented as a component of the auxiliary services 106 or as adifferent component. In certain embodiments the frontend 120 mayperiodically poll the message queue service 105 to identify and retrieveevent messages for processing. Message events may be placed in themessage queue for example by the message queue service 105, such as inresponse to when an event is detected for which the user has registeredto trigger automatic generation of a request to execute user code. Insome instances it may be desirable or more practical to detect suchevents, trigger generation of an event message, and provide the eventmessage to the message queue service 105. For example, depending on theembodiment, the message queue service 105 may be configured to allowordering of message events so that certain message events may receive ahigher priority. In another example, the message queue service 105 maybe specifically or specially configured to facilitate transportation ofcertain types of programmatic events, such as database operations,certain types of data suitable for batch processing, and so on. In oneembodiment the message queue service 105 may be configured to providestreaming, and/or ordered transport of messages (for example, as asharded set of data). The frontend 120 may then poll the message queueservice 105 and retrieve event messages for further processing by thevirtual compute system 110.

In another embodiment, instead of or in combination with using themessage queue service 105, the frontend 120 may query the eventtriggering service 106A directly to request and receive event messagesfor further processing, such as via invocation of an API provided by theevent triggering service 106A. In another embodiment, the eventtriggering service 106A may interface directly with the frontend 120 viaone or more APIs and function calls. For example, when an event isdetected and an event message is generated, the event triggering system106A may invoke an API provided by the frontend 120 to provide the eventmessage directly to the frontend 120, without necessarily providing theevent message to the message queue service 105.

A user request may specify one or more third-party libraries (includingnative libraries) to be used along with the user code. In oneembodiment, the user request includes a package file (for example, acompressed file, a ZIP file, a RAR file, etc.) containing the user codeand any libraries (and/or identifications of storage locations thereof).In some embodiments, the user request includes metadata that indicatesthe program code to be executed, the language in which the program codeis written, the user associated with the request, and/or the computingresources (e.g., memory, etc.) to be reserved for executing the programcode. For example, the program code may be provided with the request,previously uploaded by the user, provided by the virtual compute system110 (e.g., standard routines), and/or provided by third parties. In someembodiments, such resource-level constraints (e.g., how much memory isto be allocated for executing a particular user code) are specified forthe particular user code, and may not vary over each execution of theuser code. In such cases, the virtual compute system 110 may have accessto such resource-level constraints before each individual request isreceived, and the individual requests may not specify suchresource-level constraints. In some embodiments, the user request mayspecify other constraints such as permission data that indicates whatkind of permissions that the request has to execute the user code. Suchpermission data may be used by the virtual compute system 110 to accessprivate resources (e.g., on a private network).

In some embodiments, the user request may specify the behavior thatshould be adopted for handling the user request. In such embodiments,the user request may include an indicator for enabling one or moreexecution modes in which the user code associated with the user requestis to be executed. For example, the request may include a flag or aheader for indicating whether the user code should be executed in adebug mode in which the debugging and/or logging output that may begenerated in connection with the execution of the user code is providedback to the user (e.g., via a console user interface). In such anexample, the virtual compute system 110 may inspect the request and lookfor the flag or the header, and if it is present, the virtual computesystem 110 may modify the behavior (e.g., logging facilities) of thecontainer in which the user code is executed, and cause the output datato be provided back to the user. In some embodiments, the behavior/modeindicators are added to the request by the user interface provided tothe user by the virtual compute system 110. Other features such assource code profiling, remote debugging, etc. may also be enabled ordisabled based on the indication provided in the request.

In some embodiments, the virtual compute system 110 may include multiplefrontends 120. In such embodiments, a load balancer may be provided todistribute the incoming requests and/or event messages to the multiplefrontends 120, for example, in a round-robin fashion.

The warming pool manager 130 ensures that virtual machine instances areready to be used by the worker manager 140 when the virtual computesystem 110 receives a request to execute user code on the virtualcompute system 110. In the example illustrated in FIG. 1, the warmingpol manager 130 manages the warming pool 130A, which is a group(sometimes referred to as a pool) of pre-initialized and pre-configuredvirtual machine instances that may be used to service incoming user codeexecution requests. In some embodiments, the warming pool manager 130causes virtual machine instances to be booted up on one or more physicalcomputing machines within the virtual compute system 110 and added tothe warming pool 130A prior to receiving a code execution request thatwill be executed on the virtual machine instance. In other embodiments,the warming pool manager 130 communicates with an auxiliary virtualmachine instance service (e.g., an instance provisioning service 109) tocreate and add new instances to the warming pool 130A. For example, thewarming pool manager 130 may cause additional instances to be added tothe warming pool 130A based on the available capacity in the warmingpool 130A to service incoming requests. In some embodiments, the warmingpool manager 130 may utilize both physical computing devices within thevirtual compute system 110 and one or more virtual machine instanceservices to acquire and maintain compute capacity that can be used toservice code execution requests received by the frontend 120. In someembodiments, the virtual compute system 110 may comprise one or morelogical knobs or switches for controlling (e.g., increasing ordecreasing) the available capacity in the warming pool 130A. Forexample, a system administrator may use such a knob or switch toincrease the capacity available (e.g., the number of pre-bootedinstances) in the warming pool 130A during peak hours. In someembodiments, virtual machine instances in the warming pool 130A can beconfigured based on a predetermined set of configurations independentfrom a specific user request to execute a user's code. The predeterminedset of configurations can correspond to various types of virtual machineinstances to execute user codes. The warming pool manager 130 canoptimize types and numbers of virtual machine instances in the warmingpool 130A based on one or more metrics related to current or previoususer code executions.

As shown in FIG. 1, instances may have operating systems (OS) and/orlanguage runtimes loaded thereon. For example, the warming pool 130Amanaged by the warming pool manager 130 comprises instances 152, 154.The instance 152 includes an OS 152A and a runtime 152B. The instance154 includes an OS 154A. In some embodiments, the instances in thewarming pool 130A may also include containers (which may further containcopies of operating systems, runtimes, user codes, etc.), which aredescribed in greater detail below. Although the instance 152 is shown inFIG. 1 to include a single runtime, in other embodiments, the instancesdepicted in FIG. 1 may include two or more runtimes, each of which maybe used for running a different user code. In some embodiments, thewarming pool manager 130 may maintain a list of instances in the warmingpool 130A. The list of instances may further specify the configuration(e.g., OS, runtime, container, etc.) of the instances.

In some embodiments, the virtual machine instances in the warming pool130A may be used to serve any user's request. In one embodiment, all thevirtual machine instances in the warming pool 130A are configured in thesame or substantially similar manner. In another embodiment, the virtualmachine instances in the warming pool 130A may be configured differentlyto suit the needs of different users. For example, the virtual machineinstances may have different operating systems, different languageruntimes, and/or different libraries loaded thereon. In yet anotherembodiment, the virtual machine instances in the warming pool 130A maybe configured in the same or substantially similar manner (e.g., withthe same OS, language runtimes, and/or libraries), but some of thoseinstances may have different container configurations. For example, twoinstances may have runtimes for both Python and Ruby, but one instancemay have a container configured to run Python code, and the otherinstance may have a container configured to run Ruby code. In someembodiments, multiple warming pools 130A, each havingidentically-configured virtual machine instances, are provided.

The warming pool manager 130 may pre-configure the virtual machineinstances in the warming pool 130A, such that each virtual machineinstance is configured to satisfy at least one of the operatingconditions that may be requested or specified by the user request toexecute program code on the virtual compute system 110. In oneembodiment, the operating conditions may include program languages inwhich the potential user codes may be written. For example, suchlanguages may include Java, JavaScript, Python, Ruby, and the like. Insome embodiments, the set of languages that the user codes may bewritten in may be limited to a predetermined set (e.g., set of 4languages, although in some embodiments sets of more or less than fourlanguages are provided) in order to facilitate pre-initialization of thevirtual machine instances that can satisfy requests to execute usercodes. For example, when the user is configuring a request via a userinterface provided by the virtual compute system 110, the user interfacemay prompt the user to specify one of the predetermined operatingconditions for executing the user code. In another example, theservice-level agreement (SLA) for utilizing the services provided by thevirtual compute system 110 may specify a set of conditions (e.g.,programming languages, computing resources, etc.) that user requestsshould satisfy, and the virtual compute system 110 may assume that therequests satisfy the set of conditions in handling the requests. Inanother example, operating conditions specified in the request mayinclude: the amount of compute power to be used for processing therequest; the type of the request (e.g., HTTP vs. a triggered event); thetimeout for the request (e.g., threshold time after which the requestmay be terminated); security policies (e.g., may control which instancesin the warming pool 130A are usable by which user); etc.

The worker manager 140 manages the instances used for servicing incomingcode execution requests. In the example illustrated in FIG. 1, theworker manager 140 manages the active pool 140A, which is a group(sometimes referred to as a pool) of virtual machine instances that arecurrently assigned to one or more users. Although the virtual machineinstances are described here as being assigned to a particular user, insome embodiments, the instances may be assigned to a group of users,such that the instance is tied to the group of users and any member ofthe group can utilize resources on the instance. For example, the usersin the same group may belong to the same security group (e.g., based ontheir security credentials) such that executing one member's code in acontainer on a particular instance after another member's code has beenexecuted in another container on the same instance does not posesecurity risks. Similarly, the worker manager 140 may assign theinstances and the containers according to one or more policies thatdictate which requests can be executed in which containers and whichinstances can be assigned to which users. An example policy may specifythat instances are assigned to collections of users who share the sameaccount (e.g., account for accessing the services provided by thevirtual compute system 110). In some embodiments, the requestsassociated with the same user group may share the same containers (e.g.,if the user codes associated therewith are identical). In someembodiments, a request does not differentiate between the differentusers of the group and simply indicates the group to which the usersassociated with the requests belong.

As shown in FIG. 1, instances may have operating systems (OS), languageruntimes, and containers. The containers may have individual copies ofthe OS and the runtimes and user codes loaded thereon. In the example ofFIG. 1, the active pool 140A managed by the worker manager 140 includesthe instances 156, 158. The instance 156 has an OS 156A, runtimes 156B,156C, and containers 156D, 156E. The container 156D includes a copy ofthe OS 156A, a copy of the runtime 156B, and a copy of a code 156D-1.The container 156E includes a copy of the OS 156A, a copy of the runtime156C, and a copy of a code 156E-1. The instance 158 has an OS 158A,runtimes 158B, 158C, 158E, 158F, a container 158D, and codes 158G, 158H.The container 158D has a copy of the OS 158A, a copy of the runtime158B, and a copy of a code 158D-1. As illustrated in FIG. 1, instancesmay have user codes loaded thereon, and containers within thoseinstances may also have user codes loaded therein. In some embodiments,the worker manager 140 may maintain a list of instances in the activepool 140A. The list of instances may further specify the configuration(e.g., OS, runtime, container, etc.) of the instances. In someembodiments, the worker manager 140 may have access to a list ofinstances in the warming pool 130A (e.g., including the number and typeof instances). In other embodiments, the worker manager 140 requestscompute capacity from the warming pool manager 130 without havingknowledge of the virtual machine instances in the warming pool 130A.

In the example illustrated in FIG. 1, user codes are executed inisolated compute systems referred to as containers (e.g., containers156D, 156E, 158D). Containers are logical units created within a virtualmachine instance using the resources available on that instance. Forexample, the worker manager 140 may, based on information specified inthe request to execute user code, create a new container or locate anexisting container in one of the instances in the active pool 140A andassigns the container to the request to handle the execution of the usercode associated with the request. In one embodiment, such containers areimplemented as Linux containers. The virtual machine instances in theactive pool 140A may have one or more containers created thereon andhave one or more program codes associated with the user loaded thereon(e.g., either in one of the containers or in a local cache of theinstance). Each container may have credential information made availabletherein, so that user codes executing on the container have access towhatever the corresponding credential information allows them to access.

Once a request has been successfully processed by the frontend 120, theworker manager 140 finds capacity to service the request to execute usercode on the virtual compute system 110. For example, if there exists aparticular virtual machine instance in the active pool 140A that has acontainer with the same user code loaded therein (e.g., code 156D-1shown in the container 156D), the worker manager 140 may assign thecontainer to the request and cause the user code to be executed in thecontainer. Alternatively, if the user code is available in the localcache of one of the virtual machine instances (e.g., codes 158G, 158H,which are stored on the instance 158 but do not belong to any individualcontainers), the worker manager 140 may create a new container on suchan instance, assign the container to the request, and cause the usercode to be loaded and executed in the container.

If the worker manager 140 determines that the user code associated withthe request is not found on any of the instances (e.g., either in acontainer or the local cache of an instance) in the active pool 140A,the worker manager 140 may determine whether any of the instances in theactive pool 140A is currently assigned to the user associated with therequest and has compute capacity to handle the current request. If thereis such an instance, the worker manager 140 may create a new containeron the instance and assign the container to the request. Alternatively,the worker manager 140 may further configure an existing container onthe instance assigned to the user, and assign the container to therequest. For example, the worker manager 140 may determine that theexisting container may be used to execute the user code if a particularlibrary demanded by the current user request is loaded thereon. In sucha case, the worker manager 140 may load the particular library and theuser code onto the container and use the container to execute the usercode.

If the active pool 140A does not contain any instances currentlyassigned to the user, the worker manager 140 pulls a new virtual machineinstance from the warming pool 130A, assigns the instance to the userassociated with the request, creates a new container on the instance,assigns the container to the request, and causes the user code to bedownloaded and executed on the container.

The user code may be downloaded from an auxiliary service 106 such asthe storage service 108 of FIG. 1. Data 108A illustrated in FIG. 1 maycomprise user codes uploaded by one or more users, metadata associatedwith such user codes, or any other data utilized by the virtual computesystem 110 to perform one or more techniques described herein. Althoughonly the storage service 108 is illustrated in the example of FIG. 1,the virtual environment 100 may include other levels of storage systemsfrom which the user code may be downloaded. For example, each instancemay have one or more storage systems either physically (e.g., a localstorage resident on the physical computing system on which the instanceis running) or logically (e.g., a network-attached storage system innetwork communication with the instance and provided within or outsideof the virtual compute system 110) associated with the instance on whichthe container is created. Alternatively, the code may be downloaded froma web-based data store provided by the storage service 108.

Once the worker manager 140 locates one of the virtual machine instancesin the warming pool 130A that can be used to serve the user codeexecution request, the warming pool manager 130 or the worker manger 140takes the instance out of the warming pool 130A and assigns it to theuser associated with the request. The assigned virtual machine instanceis taken out of the warming pool 130A and placed in the active pool140A. In some embodiments, once the virtual machine instance has beenassigned to a particular user, the same virtual machine instance cannotbe used to service requests of any other user. This provides securitybenefits to users by preventing possible co-mingling of user resources.Alternatively, in some embodiments, multiple containers belonging todifferent users (or assigned to requests associated with differentusers) may co-exist on a single virtual machine instance. Such anapproach may improve utilization of the available compute capacity.

In some embodiments, the virtual compute system 110 may maintain aseparate cache in which user codes are stored to serve as anintermediate level of caching system between the local cache of thevirtual machine instances and a web-based network storage (e.g.,accessible via the network 104). The various scenarios that the workermanager 140 may encounter in servicing the request are described ingreater detail below with reference to FIG. 4.

After the user code has been executed, the worker manager 140 may teardown the container used to execute the user code to free up theresources it occupied to be used for other containers in the instance.Alternatively, the worker manager 140 may keep the container running touse it to service additional requests from the same user. For example,if another request associated with the same user code that has alreadybeen loaded in the container, the request can be assigned to the samecontainer, thereby eliminating the delay associated with creating a newcontainer and loading the user code in the container. In someembodiments, the worker manager 140 may tear down the instance in whichthe container used to execute the user code was created. Alternatively,the worker manager 140 may keep the instance running to use it toservice additional requests from the same user. The determination ofwhether to keep the container and/or the instance running after the usercode is done executing may be based on a threshold time, the type of theuser, average request volume of the user, and/or other operatingconditions. For example, after a threshold time has passed (e.g., 5minutes, 30 minutes, 1 hour, 24 hours, 30 days, etc.) without anyactivity (e.g., running of the code), the container and/or the virtualmachine instance is shutdown (e.g., deleted, terminated, etc.), andresources allocated thereto are released. In some embodiments, thethreshold time passed before a container is torn down is shorter thanthe threshold time passed before an instance is torn down.

In some embodiments, the virtual compute system 110 may provide data toone or more of the auxiliary services 106 as it services incoming codeexecution requests. For example, the virtual compute system 110 maycommunicate with the monitoring/logging/billing services 107. Themonitoring/logging/billing services 107 may include: a monitoringservice for managing monitoring information received from the virtualcompute system 110, such as statuses of containers and instances on thevirtual compute system 110; a logging service for managing logginginformation received from the virtual compute system 110, such asactivities performed by containers and instances on the virtual computesystem 110; and a billing service for generating billing informationassociated with executing user code on the virtual compute system 110(e.g., based on the monitoring information and/or the logginginformation managed by the monitoring service and the logging service).In addition to the system-level activities that may be performed by themonitoring/logging/billing services 107 (e.g., on behalf of the virtualcompute system 110) as described above, the monitoring/logging/billingservices 107 may provide application-level services on behalf of theuser code executed on the virtual compute system 110. For example, themonitoring/logging/billing services 107 may monitor and/or log variousinputs, outputs, or other data and parameters on behalf of the user codebeing executed on the virtual compute system 110. Although shown as asingle block, the monitoring, logging, and billing services 107 may beprovided as separate services.

In some embodiments, the worker manager 140 may perform health checks onthe instances and containers managed by the worker manager 140 (e.g.,those in the active pool 140A). For example, the health checks performedby the worker manager 140 may include determining whether the instancesand the containers managed by the worker manager 140 have any issues of(1) misconfigured networking and/or startup configuration, (2) exhaustedmemory, (3) corrupted file system, (4) incompatible kernel, and/or anyother problems that may impair the performance of the instances and thecontainers. In one embodiment, the worker manager 140 performs thehealth checks periodically (e.g., every 5 minutes, every 30 minutes,every hour, every 24 hours, etc.). In some embodiments, the frequency ofthe health checks may be adjusted automatically based on the result ofthe health checks. In other embodiments, the frequency of the healthchecks may be adjusted based on user requests. In some embodiments, theworker manager 140 may perform similar health checks on the instancesand/or containers in the warming pool 130A. The instances and/or thecontainers in the warming pool 130A may be managed either together withthose instances and containers in the active pool 140A or separately. Insome embodiments, in the case where the health of the instances and/orthe containers in the warming pool 130A is managed separately from theactive pool 140A, the warming pool manager 130, instead of the workermanager 140, may perform the health checks described above on theinstances and/or the containers in the warming pool 130A.

In some embodiments, the virtual compute system 110 is adapted to beginexecution of the user code shortly after it is received (e.g., by thefrontend 120). A time period can be determined as the difference in timebetween initiating execution of the user code (e.g., in a container on avirtual machine instance associated with the user) and receiving arequest to execute the user code (e.g., received by a frontend). Anothertime period can be determined as the difference in time between (1)detection of an event on an event-triggering service and (2a) receivinga request to execute the user code (e.g., received by a frontend) and/or(2b) initiating execution of the user code (e.g., in a container on avirtual machine instance associated with the user). Another time periodcan be determined as the difference in time between (1) retrieving,accessing, or receiving an event message (e.g., directly or indirectlyfrom on an event-triggering service) and (2) initiating processing of arequest to execute the user code (e.g., in a container on a virtualmachine instance associated with the user). The virtual compute system110 is adapted to begin execution of the user code within a time periodthat is less than a predetermined duration. In one embodiment, thepredetermined duration is 500 ms. In another embodiment, thepredetermined duration is 300 ms. In another embodiment, thepredetermined duration is 100 ms. In another embodiment, thepredetermined duration is 50 ms. In another embodiment, thepredetermined duration is 10 ms. In another embodiment, thepredetermined duration may be any value chosen from the range of 10 msto 500 ms. In some embodiments, the virtual compute system 110 isadapted to begin execution of the user code within a time period that isless than a predetermined duration if one or more conditions aresatisfied. For example, the one or more conditions may include any oneof: (1) the user code is loaded on a container in the active pool 140Aat the time the request is received; (2) the user code is stored in thecode cache of an instance in the active pool 140A at the time therequest is received; (3) the active pool 140A contains an instanceassigned to the user associated with the request at the time the requestis received; or (4) the warming pool 130A has capacity to handle therequest at the time the request is received.

The worker manager 140 may include an instance allocation unit forfinding compute capacity (e.g., containers) to service incoming codeexecution requests and a user code execution module for facilitating theexecution of user codes on those containers. An example configuration ofthe frontend 120 is described in greater detail below with reference toFIG. 2.

FIG. 2 depicts a general architecture of a computing system (referencedas frontend 120) that processes event messages for user requests toexecute program codes in the virtual compute system 110. The generalarchitecture of the frontend 120 depicted in FIG. 2 includes anarrangement of computer hardware and software modules that may be usedto implement aspects of the present disclosure. The hardware modules maybe implemented with physical electronic devices, as discussed in greaterdetail below. The frontend 120 may include many more (or fewer) elementsthan those shown in FIG. 2. It is not necessary, however, that all ofthese generally conventional elements be shown in order to provide anenabling disclosure. Additionally, the general architecture illustratedin FIG. 2 may be used to implement one or more of the other componentsillustrated in FIG. 1. As illustrated, the frontend 120 includes aprocessing unit 190, a network interface 192, a computer readable mediumdrive 194, an input/output device interface 196, all of which maycommunicate with one another by way of a communication bus. The networkinterface 192 may provide connectivity to one or more networks orcomputing systems. The processing unit 190 may thus receive informationand instructions from other computing systems or services via thenetwork 104. The processing unit 190 may also communicate to and frommemory 180 and further provide output information for an optionaldisplay (not shown) via the input/output device interface 196. Theinput/output device interface 196 may also accept input from an optionalinput device (not shown).

The memory 180 may contain computer program instructions (grouped asmodules in some embodiments) that the processing unit 190 executes inorder to implement one or more aspects of the present disclosure. Thememory 180 generally includes RAM, ROM and/or other persistent,auxiliary or non-transitory computer-readable media. The memory 180 maystore an operating system 184 that provides computer programinstructions for use by the processing unit 190 in the generaladministration and operation of the worker manager 140. The memory 180may further include computer program instructions and other informationfor implementing aspects of the present disclosure. For example, in oneembodiment, the memory 180 includes a user interface unit 182 thatgenerates user interfaces (and/or instructions therefor) for displayupon a computing device, e.g., via a navigation and/or browsinginterface such as a browser or application installed on the computingdevice. In addition, the memory 180 may include and/or communicate withone or more data repositories (not shown), for example, to access userprogram codes and/or libraries.

In addition to and/or in combination with the user interface unit 182,the memory 180 may include an event/request processing unit 188 whichmay include an event message polling unit 186A and an event messageconversion unit 186B that may be executed by the processing unit 190. Inone embodiment, the user interface unit 182, the event message pollingunit 186A, and the event message conversion unit 186B individually orcollectively implement various aspects of the present disclosure, e.g.,processing an event message for a request to executed user code, asdescribed herein. In another embodiment, a separate polling service maybe implemented, for example via a polling fleet configured to poll anevent source or a message queue and perform at least an initial messageconversion or processing to prepare the event message for furtherprocessing by the frontend 120 and/or another component of the virtualcompute system 100.

The event message polling unit 186A periodically polls for eventmessages to be processed into requests to execute user code. Forexample, the event message polling unit 186A may periodically access amessage queue, such as the message queue service 105 or any othermessage queue service or message bus, to determine or detect whether anevent message has been placed in the message queue for processing by thevirtual compute system 110. An event message may be placed in themessage queue according to, for example, the routine described hereinwith reference to FIG. 3. In response to determining or detecting anevent message in the message queue, the event message polling unit 186Amay retrieve the message event from the message queue and initiatefurther processing of the event message as further described herein. Inanother embodiment, the event message polling unit 186A may poll theevent-triggering service 106A directly rather than from a message queue.For example, some event-triggering services such as certain types ofdatabases may support direct polling of event messages that need notnecessarily rely on an intermediary message queue.

The event message conversion unit 186B manages the conversion of theevent message (e.g., as accessed or retrieved from a message queue suchas the message queue 105) into a request to execute user code (e.g.,ready for further processing in accordance with the processes describedin U.S. application Ser. No. 14/502,992 titled “THREADING AS A SERVICE,”filed on Sep. 30, 2014, which was previously incorporated by referencein its entirety above). Conversion of the event message is described inmore detail with reference to FIG. 4 herein. In one embodiment the eventmessage is generated in a format representative of a remote procedurecall to facilitate rapid conversion and/or immediate function invocationby the virtual compute system 110 when the event message is processed.Such an implementation enables a high degree of functional transparencyand reduced latency between an auxiliary system responding to an eventtrigger and the virtual compute system 110 processing the event messagegenerated by the auxiliary system responsive to the event trigger.

While the event message polling unit 186A and the event messageconversion unit 186B are shown in FIG. 2 as part of the frontend 120, inother embodiments, all or a portion of the event message polling unit186A and the event message conversion unit 186B may be implemented byother components of the virtual compute system 110 and/or anothercomputing device. For example, in certain embodiments of the presentdisclosure, another computing device in communication with the virtualcompute system 110 may include several modules or components thatoperate similarly to the modules and components illustrated as part ofthe frontend 120. In some embodiments, the frontend 120 may furtherinclude components other than those illustrated in FIG. 2.

Turning now to FIG. 3, a routine 300 implemented by one or morecomponents of the auxiliary service 106, such as the storage service108, configured to operate as an event triggering service 106A, will bedescribed. Although routine 300 is described with regard toimplementation by event triggering service 106A, one skilled in therelevant art will appreciate that alternative components, such as a userdevice 102 or the virtual compute system 110, may implement routine 300or that one or more of the blocks may be implemented by a differentcomponent or in a distributed manner.

At block 302 of the illustrative routine 300, the event triggeringservice 106A detects an event or activity that has been designated totrigger or activate execution of a user code on the virtual computesystem 110. For example, in some embodiments the event triggeringservice 106A may be configured to enable or activate event notificationsfor one or more events. In one embodiment the event trigger andnotification configuration settings may be provided or specified by auser. For example, when the user provides or uploads user code to thevirtual compute system 110 and/or to the storage service 108, the usermay at that time specify one or more events for which the eventtriggering service 106A should listen, and which corresponding functionsor routines of the user code are to be executed in response to detectionof the one or more events. As one illustrative example, a user mayupload (or have previously uploaded or otherwise provided to the virtualcompute system 110) a user code to generate a thumbnail image, andfurther specify that the code to generate a thumbnail image is to beexecuted in response to an end user uploading a new image to anauxiliary system (such as an image sharing system). In this example theimage sharing system will then monitor or detect an image upload event.In some embodiments the event trigger and notification configurationsettings may be provided or specified by a configuration file or otherdata format that may be provided, for example, with the user code. Invarious embodiments, the user uploading the user code and the end userperforming some other action with respect to the auxiliary serviceconfigured as an event-triggering service (such as uploading a newimage) may be separate and distinct users or entities.

Next, at block 304, the event triggering service 106A generates an eventmessage in association with the detected activity/event. For example,the event triggering service 106A may generate the event messageaccording to the event trigger and notification configuration settingspreviously provided by the user. The configuration settings can specify,for example, a schema, a code model, or an API associated with the usercode to be executed by the virtual compute system in response to theevent being triggered. For example the event message may be generated tocomprise, among other things, a user account identifier associated withthe user, a function identifier to identify a function to be invoked onthe virtual compute system, and one or more event message parametersincluding any input parameters (required and/or optional) to be providedwith the function invocation.

In some embodiments, the event message may include data or metadata thatindicates the program code to be executed, the language in which theprogram code is written, the user associated with the request, and/orthe computing resources (e.g., memory, etc.) to be reserved forexecuting the program code. For example, the event message may specifythat the user code is to be executed on “Operating System A” using“Language Runtime X.” When the event message is processed by the virtualcompute system 110 (see, e.g., FIG. 4), the virtual compute system 110or one of its components may locate a virtual machine instance that hasbeen pre-configured with “Operating System A” and “Language Runtime X”and assigned to the user. The virtual compute system 110 may then createa container on the virtual machine instance for executing the user codetherein. If a container having the code already exists on the virtualmachine instance, the virtual compute system 110 can buffer the currentrequest for execution on the container once the container becomesavailable.

In one embodiment the format of the event message (or at least a portionof the event message) may represent a standard remote procedure callsuch that the event triggering service 106A may only need to performminimal processing to provide relevant information in the event messagethat may be needed to invoke the function on the virtual compute system.For example, such a standard remote procedure call format may enable anauxiliary system 106 which runs a different operating system or languageruntime than the virtual compute system 110 to seamlessly communicatewith the virtual compute system 110 via the event message generated insuch a standard format. In one embodiment the format of the remoteprocedure call may be provided by the user and designed to match orcorrespond to the user code to be executed. For example, when an imageupload event is detected, the format of the event message may representa remote procedure call to a function to be executed in response on thevirtual compute system, such as “invoke (generateThumbnail, userID,imageName, imagePath)”, or “generateThumbnail (userID, imageName,imagePath),” or similar.

In some embodiments, such as certain instances where a trusted or securerelationship is established between the event triggering service 106Aand the virtual compute system 110, the event message may furthercomprise the user code to be executed by the virtual compute system 110.For example, the user may provide the user code to the event triggeringservice 106A instead of or in addition to providing the user code to thevirtual compute system 110, and further designate that the user code isto be provided with the event message to the virtual compute system 110for execution at runtime. In another embodiment, the event message maycomprise a location (such as a URI) of the user code to be executed bythe virtual compute system 110, such that the virtual compute system 110can remotely invoke the user code via the URI.

At block 306, the event triggering service 106A provides the eventmessage for further processing by the virtual compute system. Forexample, in one embodiment the event message is provided to a messagequeue, such as the message queue 105. The message queue service 105 maybe a component of the auxiliary system 106 (e.g., as shown in FIG. 1) orit may be a separate system or service in communication with theauxiliary system 106 and/or the virtual compute system 110 over thenetwork 160. The particular format of the event message may be based atleast in part on a specification associated with the message queue beingused to transport the event message. Additionally, a particular messagequeue being used may be based on the type of event message beinggenerated and provided to the virtual compute system. For example, aparticular message queue may be suited to transport messages relating todatabase operations, and thus an event message generated in response toa database event trigger may be provided using the particular messagequeue. How the virtual compute system accesses and processes the eventmessage is described in greater detail below with reference to FIG. 4.In another embodiment, the event message may be provided or madeavailable for access by the virtual compute system 110 directly, withoutthe need for an intermediary message queue. For example, the eventtriggering service 106A may provide or enable an API which the virtualcompute system 110 may invoke in order to request one or more availableevent messages from the event triggering service 106A. The virtualcompute system 100 may then invoke the API, for example on a periodicbasis, instead of or in combination with polling a message queue inorder to access and/or retrieve event messages for processing.

While the routine 300 of FIG. 3 has been described above with referenceto blocks 302-306, the embodiments described herein are not limited assuch, and one or more blocks may be omitted, modified, or switchedwithout departing from the spirit of the present disclosure.

Turning now to FIG. 4, a routine 400 implemented by one or morecomponents of the virtual compute system 110 (e.g., the frontend 120)will be described. Although routine 400 is described with regard toimplementation by the frontend 120, one skilled in the relevant art willappreciate that alternative components may implement routine 400 or thatone or more of the blocks may be implemented by a different component orin a distributed manner.

At block 402 of the illustrative routine 400, the frontend 120 mayoptionally periodically poll a message queue (e.g., message queue 105)for an event message which may represent a request to execute user code.For example, the block 402 may continue the event messaging process fromthe block 306 of FIG. 3 in scenarios where the event triggering service106A provides event messages via the message queue.

Next, at block 404, the frontend 120 accesses or retrieves an eventmessage for processing by the virtual compute system 110. In oneembodiment, the event message is accessed or retrieved from the messagequeue. Retrieval of the event message removes the event message from themessage queue to prevent duplication of further processing associatedwith the event. In another embodiment, the event message may be accessedor retrieved from the event triggering service directly, such as byinvocation of an API provided by the event trigger service by which thefrontend 120 can request and receive event messages ready for processingby the virtual compute system 110. The event message can include orcomprise any of the information and metadata described above withreference to FIG. 3, including for example, a user account identifierassociated with the user, a function identifier to identify a functionto be invoked on the virtual compute system, and one or more eventmessage parameters including any input parameters (required and/oroptional) to be provided with the function invocation.

At block 406, the frontend 120 converts the event message into a requestto execute user code, such that the request to execute user code may befurther processed by the virtual compute system 110 (including, forexample, as described in U.S. application Ser. No. 14/502,992 titled“THREADING AS A SERVICE,” filed on Sep. 30, 2014, which was previouslyincorporated by reference in its entirety above). Conversion of theevent message may involve parsing the event message to identify and/orextract the function identifier, any input parameters, and othermetadata that may be needed to generate a request to execute the usercode which was designated by the user to be executed in response to theevent trigger. For example, the event message may include or comprise atleast one or more of the following: information related to an eventpayload (e.g., event data), which may conform to a known or definedschema or other format; an event wrapper or “envelope” provided, forexample, by the event message bus or by the event-triggering service(for example, which may part of an implicit lease on the event messageprovided by the message queue service); and/or event metadata associatedwith the event, including an identity for which the event message wassigned, an identity of the event producer or source of the event trigger(for example, which event-triggering service triggered the event), aname or owner of the message queue on which the event message wastransported; and so on.

As described with reference to FIG. 3, in one embodiment the format ofthe event message may represent a standard remote procedure call, suchthat once retrieved from the message queue, the frontend 120 may onlyneed to perform minimal processing to generate a corresponding requestto execute the user code. For example, when an image upload event isdetected, the format of the event message may represent a remoteprocedure call to a function to be executed in response on the virtualcompute system, such as “invoke (generateThumbnail, userID, imageName,imagePath)”, or “generateThumbnail (userID, imageName, imagePath),” orsimilar. Thus, in one embodiment, the frontend 120 may extract thisremote procedure call and immediately invoke the specified function toinitiate a request. Further, as discussed above with reference to FIG.3, the request to execute the user code may further specify that theuser code is to be executed on “Operating System A” using “LanguageRuntime X,” which may be included as additional inputs for the requestto execute the user code.

At block 408, the frontend 120 may optionally verify security accessand/or authenticate the user associated with a user account identifierprovided with the event message and determine that the user isauthorized to access the specified user code. In some embodiments thesecurity and/or authentication may be omitted or performed in a separateprocess or as part of the processing of the request to execute the usercode. In some embodiments the security and/or authentication may beperformed earlier in the routine 400, such as prior to the conversionperformed at block 406.

At block 410, the frontend 120 provides the request to execute the usercode to the virtual compute system 110. In certain embodiments thefrontend 120 itself may perform further processing of the request, forexample as described in U.S. application Ser. No. 14/502,992 titled“THREADING AS A SERVICE,” filed on Sep. 30, 2014, which was previouslyincorporated by reference in its entirety above. The request can includea program code composed in a programming language. Various programlanguages including Java, PHP, C++, Python, etc. can be used to composethe user code. The request can include configuration informationrelating to code-execution requirements. For example, the request caninclude information about program language in which the program code iswritten, information about language runtime and/or language library toexecute the user code. The configuration information need not includeany specific information regarding the virtual machine instance that canhost the user code.

While the routine 400 of FIG. 4 has been described above with referenceto blocks 402-410, the embodiments described herein are not limited assuch, and one or more blocks may be omitted, modified, or switchedwithout departing from the spirit of the present disclosure. Forexample, the block 402 may be modified such that the frontend 120receives an event message from the user device 102.

The routine 400 of FIG. 4 may include different processes or routineswhich may be performed in a different order. One alternative example isprovided as follows, although other variations may be possible. First,an event message may be received or accessed by the frontend 120, whichparses the event message (using a schema if one is available). Thefrontend 120 may combine the parsed event message with additional eventmetadata (e.g., an event wrapper, information about the message queueidentity or source of the event trigger, and so on) in order todetermine or establish information about the event, the source or ownerof the event, and other information which may be provided to the virtualcompute system 110. The frontend 120 may then perform at least aninitial authorization and/or security check as needed to verify securedaccess and related execution of user code. The frontend 120 may thenevaluate the parsed event message and additional event metadata in orderto route the message to an appropriate program or user code to be calledin response to the event. The frontend 120 may then perform mapping ofthe event message into a request to execute the user code by, forexample, converting the content of the message and/or the event metadatainto arguments, variables, and other inputs in the programming languageof the user code selected to process the event message. Additionalinformation may be added to the request to execute the user codeincluding, for example, an identity associated with the signer orprovider of the event message. The frontend 120 may then call afunction, method, or other entry point in the programming language(optionally with conditions based on aspects of the event message and/orevent metadata) to initiate processing of the request.

During processing of the request to execute user code the frontend 120may continue to perform additional processes to facilitate processing ofthe event message or payload. For example, if the original event messageor payload comprised an aggregate collection of one or more sub-events,each sub-event may be relayed to the virtual compute system 110 forexecution via the user code one at a time. The frontend 120 may beconfigured to manage splitting the original, aggregate event messagepayload into multiple single events. The frontend 120 may also beconfigured to, for example, facilitate intermediate or aggregatecheckpoint services which may be required as part of processing of theoriginal event message. For example, an aggregate event messagecomprising multiple events may require some of first events to beprocessed and completed first before later, second or tertiary events;in this case the frontend 120 may be further configured to facilitateprocessing of the first events, check for status of completion of thefirst events before routing the later, second or tertiary events forprocessing/execution by the virtual compute system.

After processing/execution of the user code for an event message, thefrontend 120 may be further configured to provide additionalpost-processing. For example, the frontend 120 may perform certaincleanup operations (for example, releasing a lease on the associatedevent message/wrapper), perform result calculations, provide returnvalues (if needed), perform checkpoint operations (which, for example,as described above, may occur during processing or in between processingof sub-events related to an aggregate event message), and so on. In someembodiments, the frontend 120 may perform logging, monitoring,alarming/notifications, and/or other reporting associated with thecompletion (successful or unsuccessful) of the event on behalf of theuser program. In some cases such logging, monitoring, and so on may beperformed in addition to any logging, monitoring, and related processesperformed during execution of the user code itself. For example, thefrontend 120 may be configured to report on the outcome of the event(and related execution of user code in response to the event), forexample back to the event-triggering service 106A or to the user.

It will be appreciated by those skilled in the art and others that allof the functions described in this disclosure may be embodied insoftware executed by one or more physical processors of the disclosedcomponents and mobile communication devices. The software may bepersistently stored in any type of non-volatile storage.

Conditional language, such as, among others, “can,” “could,” “might,” or“may,” unless specifically stated otherwise, or otherwise understoodwithin the context as used, is generally intended to convey that certainembodiments include, while other embodiments do not include, certainfeatures, elements and/or steps. Thus, such conditional language is notgenerally intended to imply that features, elements and/or steps are inany way required for one or more embodiments or that one or moreembodiments necessarily include logic for deciding, with or without userinput or prompting, whether these features, elements and/or steps areincluded or are to be performed in any particular embodiment.

Any process descriptions, elements, or blocks in the flow diagramsdescribed herein and/or depicted in the attached figures should beunderstood as potentially representing modules, segments, or portions ofcode which include one or more executable instructions for implementingspecific logical functions or steps in the process. Alternateimplementations are included within the scope of the embodimentsdescribed herein in which elements or functions may be deleted, executedout of order from that shown or discussed, including substantiallyconcurrently or in reverse order, depending on the functionalityinvolved, as would be understood by those skilled in the art. It willfurther be appreciated that the data and/or components described abovemay be stored on a computer-readable storage medium and loaded intomemory of the computing device using a drive mechanism associated with acomputer readable storing the computer executable components such as aCD-ROM, DVD-ROM, or network interface. Further, the component and/ordata can be included in a single device or distributed in any manner.Accordingly, general purpose computing devices may be configured toimplement the processes, algorithms, and methodology of the presentdisclosure with the processing and/or execution of the various dataand/or components described above.

It should be emphasized that many variations and modifications may bemade to the above-described embodiments, the elements of which are to beunderstood as being among other acceptable examples. All suchmodifications and variations are intended to be included herein withinthe scope of this disclosure and protected by the following claims.

What is claimed is:
 1. A system for processing event messages forrequests to execute program code on one or more virtual machineinstances, the system comprising: an electronic data store configured tostore at least a program code of a user; and a front end computingsystem comprising one or more hardware computing devices executingspecific computer-executable instructions, said front end computingsystem in communication with (1) the electronic data store, (2) amessage queue system and (3) a virtual compute system adapted to receiveuser requests, the front end computing system configured to at least:access, from the message queue system, an event message generated by anevent-originating service, said event message comprising at least a useraccount identifier and programmatic information organized in a schemausable for execution of the program code, said programmatic informationindicating at least (1) a function of the program code to execute inresponse to an event which triggered generation of the event message and(2) one or more event message parameters for execution of the programcode; retrieve, from the message queue system, the event message, themessage being retrieved at a first time; convert, based on theprogrammatic information and the schema, the event message into arequest to execute the program code, said request comprising at leastthe user account identifier and one or more input parameterscorresponding to at least some of the one or more event messageparameters; and provide, to the virtual compute system, the request toexecute the program code, wherein the request comprises at least some ofthe programmatic information for executing the program code, and whereinthe virtual computing system is configured to begin executing theprogram code at a second time, wherein a time period determined as adifference between the first time and the second time is shorter than apredetermined duration.
 2. The system of claim 1, wherein theevent-originating service is a remote storage system, and wherein theevent message is generated in response to a data file being uploaded tothe remote storage system.
 3. The system of claim 1, wherein theevent-originating service is a database system, and wherein the eventmessage is generated in response to a database table being updated inthe database system.
 4. The system of claim 1, wherein the predeterminedduration is 100 ms.
 5. A system, comprising: a virtual compute systemcomprising one or more hardware computing devices executing specificcomputer-executable instructions and configured to at least: receive anevent message generated by an event-originating service at a first time,said event message comprising at least a user account identifier andevent metadata for execution of a program code, said event metadataidentifying a function of the program code to execute and one or moreinput parameters to the function; convert, based on the event metadata,the event message into a request to execute the program code on thevirtual compute system, said request comprising configurationinformation for executing the program code, said configurationinformation comprising at least the user account identifier, thefunction of the program code to execute and the one or more inputparameters to the function; and initiate processing of the request toexecute the program code, wherein the virtual compute system is furtherconfigured to begin executing the program code at a second time, whereina time period determined as a difference between the first time and thesecond time is shorter than a predetermined duration.
 6. The system ofclaim 5, wherein the event-originating service is a remote storagesystem, and wherein the event message is generated in response to a datafile being uploaded to the remote storage system.
 7. The system of claim5, wherein the event-originating service is a database system, andwherein the event message is generated in response to a database tablebeing updated in the database system.
 8. The system of claim 5, whereinthe event-originating service is provided by a third party computingsystem separate and distinct from the virtual compute system.
 9. Thesystem of claim 5, wherein the configuration information is formattedaccording to a shared schema used by both the event-originating serviceand the virtual compute system to process event messages related to thefunction of the program code to execute.
 10. The system of claim 9,wherein the shared schema is in the form of a remote procedure call. 11.The system of claim 5, wherein the event metadata includes an indicatorof at least (1) an operating system on which the program code is to beexecuted and (2) a program language in which the program code iswritten.
 12. A computer-implemented method comprising: as implemented byone or more computing devices configured with specific executableinstructions, querying an intermediary message system for an eventmessage generated by an event-originating service at a first time, saidevent message comprising at least a user account identifier and eventmetadata for execution of a program code, said event metadataidentifying a function of the program code to execute and one or moreinput parameters to the function; retrieving, from a message queuesystem, the event message; converting, based on the event metadata, theevent message into a request to execute the program code on a virtualcompute system, said request comprising configuration information forexecuting the program code, said configuration information comprising atleast the user account identifier, the function of the program code toexecute and the one or more input parameters to the function; andinitiating processing of the request to execute the program code,wherein the virtual compute system is configured to begin executing theprogram code at a second time, wherein a time period determined as adifference between the first time and the second time is shorter than apredetermined duration.
 13. The computer-implemented method of claim 12,wherein the event-originating service is provided by a third partycomputing system separate and distinct from the virtual compute system.14. The computer-implemented method of claim 12, wherein theconfiguration information is formatted according to a shared schema usedby both the event-originating service and the virtual compute system toprocess event messages related to the function of the program code toexecute.
 15. The computer-implemented method of claim 14, wherein theshared schema is formatted according to a definition provided in asoftware developer kit (“SDK”).
 16. The computer-implemented method ofclaim 12, wherein the event metadata includes at least a portion of theprogram code.
 17. A computer-readable, non-transitory storage mediumstoring computer executable instructions that, when executed by one ormore computing devices, configure the one or more computing devices toperform operations comprising: accessing an event message generated byan auxiliary service, said event message comprising at least a useraccount identifier and event metadata for execution of a program code ona virtual compute system, said event metadata identifying a function ofthe program code to execute and one or more input parameters to thefunction, said accessing occurring at a first time; converting, based onthe event metadata, the event message into a request to execute theprogram code on the virtual compute system, said request comprisingconfiguration information for executing the program code, saidconfiguration information comprising at least the user accountidentifier, the function of the program code to execute and the one ormore input parameters to the function; and initiating processing of therequest to execute the program code, wherein the virtual compute systemis configured to begin executing the program code at a second time,wherein a time period determined as a difference between the first timeand the second time is shorter than a predetermined duration.
 18. Thecomputer-readable, non-transitory storage medium of claim 17, whereinthe auxiliary service is provided by a third party computing systemseparate and distinct from the virtual compute system.
 19. Thecomputer-readable, non-transitory storage medium of claim 17, whereinthe auxiliary service is a remote storage system, wherein the eventmessage is indicative of a data file upload event on the remote storagesystem, and wherein the function of the program code to execute is afile upload event handler designated to be executed in response todetection of the data file upload event on the remote storage system.20. The computer-readable, non-transitory storage medium of claim 17,wherein the event message is accessed from an intermediary messagesystem.